package com.yqg.protection.cover;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * @author zxf
 * @ClassName: VideoTypeConverter
 */
public class VideoTypeConverter implements Converter<Integer> {

    @Override
    public Class supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if ("海康".equals(cellData.getStringValue())) {
            return 0;
        } else if ("萤石".equals(cellData.getStringValue())) {
            return 1;
        } else {
            return 2;
        }
    }

    @Override
    public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if (value == 0) {
            return new CellData("海康");
        } else if (value == 1) {
            return new CellData("萤石");
        } else {
            return new CellData("大华");
        }
    }

}

